import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
const store = require('@/store/index')

Component({
  behaviors: [storeBindingsBehavior],

  storeBindings: {
    store,
    fields: {
      counter: store => store.counter, // 绑定属性的第一种方式
      squareOfCounter: 'squareOfCounter' // 绑定属性的第二种方式
    },
    actions: {
      increment: 'increment',
      incrementWithStep: 'incrementWithStep'
    }
  },

  methods: {
    onTap() {
      this.incrementWithStep(7)
    }
  },

  lifetimes: {
    ready() {
      // 在 Component 使用 MobX
      console.log(this.data.counter)
      console.log(this.data.squareOfCounter)
      console.log(this.increment)
      console.log(this.incrementWithStep)
    }
  }
})